<template>
  <div>
    <el-form :model="detailObj"  ref="ruleForm" label-width="140px" class="demo-ruleForm" :inline="true">
            <el-form-item label="任务单号" prop="taskNo">
              <el-input v-model="detailObj.taskNo" class="width220" disabled></el-input>
            </el-form-item>
            <el-form-item label="任务流水号" prop="taskSerialNo" v-if="type!=='insert'">
              <el-input v-model="detailObj.taskSerialNo" class="width220" disabled></el-input>
            </el-form-item>
            <el-form-item label="生产令号" prop="makeNo">
              <el-input v-model="detailObj.makeNo" class="width220" disabled></el-input>
            </el-form-item>
            <el-form-item label="图纸序号" prop="drawNo">
              <el-input v-model="detailObj.drawNo" class="width220" :disabled="editDisalbe"></el-input>
            </el-form-item>
            <el-form-item label="自定义编码" prop="code"  v-if="type!=='insert'">
              <el-input v-model="detailObj.code" class="width220" disabled></el-input>
            </el-form-item>
            <el-form-item label="优先级" prop="priority">
               <el-input v-model="detailObj.priority" class="width220" disabled></el-input>
            </el-form-item>
            <el-form-item label="计划属性" prop="planAttribute">
              <el-input v-model="detailObj.planAttribute" class="width220" disabled ></el-input>
            </el-form-item>
            <el-form-item label="月度计划" prop="monthPlan">
              <el-input v-model="detailObj.monthPlan" class="width220" disabled></el-input>
            </el-form-item>
            <el-form-item label="计划下发时间" prop="issueDate">
              <el-date-picker v-model="detailObj.issueDate" type="datetime" placeholder="计划下发时间" class="width220 noMargin" disabled></el-date-picker>
            </el-form-item>
            <el-form-item label="外包计划完成时间" prop="wbPlanFinsihDate">
              <el-date-picker v-model="detailObj.wbPlanFinsihDate" type="datetime"  placeholder="外包完成时间" class="width220 noMargin" :disabled="editDisalbe"></el-date-picker>
            </el-form-item>
            <el-form-item label="计划完成时间" prop="planFinsihDate">
              <el-date-picker v-model="detailObj.planFinsihDate" type="datetime" placeholder="计划完成时间" class="width220 noMargin" :disabled="editDisalbe"></el-date-picker>
            </el-form-item>
            <el-form-item label="件数" prop="nums">
              <el-input v-model="detailObj.nums" class="width220" :disabled="editDisalbe" ></el-input>
            </el-form-item>
            <el-form-item label="图纸编号" prop="drawCode">
              <el-input v-model="detailObj.drawCode" class="width220" disabled></el-input>
            </el-form-item>
            <el-form-item label="图纸名称" prop="drawName">
              <el-input v-model="detailObj.drawName" class="width220" disabled ></el-input>
            </el-form-item>
             <el-form-item label="项目图纸张数" prop="drawNums">
              <el-input v-model="detailObj.drawNums" class="width220" :disabled="editDisalbe" ></el-input>
            </el-form-item>
            <el-form-item label="批次号" prop="batch">
              <el-input v-model="detailObj.batch" class="width220" :disabled="editDisalbe" ></el-input>
            </el-form-item>
            <el-form-item label="自带原料" prop="isHasMaterial">
              <el-select v-model="detailObj.isHasMaterial" placeholder="请选择是否自带原料" class="width220" disabled>
                <el-option label="自备原料" :value="1"></el-option>
                <el-option label="需要采购" :value="0"></el-option>
              </el-select>
            </el-form-item>
            <el-form-item label="客户" prop="customerName"  v-if="type==='insert'">
               <el-autocomplete  class="width220" v-model="detailObj.customerName.name" :fetch-suggestions="querySearchAsync" placeholder="请输入供应商名称" @select="handleSelect" :disabled="editDisalbe"></el-autocomplete>
            </el-form-item>
            <el-form-item label="物料到达时间" prop="materialArriveTime" v-if="type==='update'">
              <el-input v-model="detailObj.materialArriveTime" disabled class="width220" ></el-input>
            </el-form-item>
            <el-form-item label="物料到达确认人" prop="materialArrivePersonName" v-if="type==='update'">
              <el-input v-model="detailObj.materialArrivePersonName" disabled class="width220" ></el-input>
            </el-form-item>
            <el-form-item label="物料下料时间" prop="materialTailorTime" v-if="type==='update'">
              <el-input v-model="detailObj.materialTailorTime" disabled class="width220" ></el-input>
            </el-form-item>
            <el-form-item label="物料下料人" prop="materialTailorPersonName" v-if="type==='update'">
              <el-input v-model="detailObj.materialTailorPersonName" disabled class="width220" ></el-input>
            </el-form-item>
            <el-form-item label="备注" prop="remark" v-if="type==='update'">
              <el-input v-model="detailObj.remark"  class="width220" type="textarea"></el-input>
            </el-form-item>
            <el-form-item label="导入人" prop="importerName" v-if="type==='update'">
              <el-input v-model="detailObj.importerName" disabled class="width220" ></el-input>
            </el-form-item>
            <el-form-item label="导入时间" prop="importDate" v-if="type==='update'">
              <el-input v-model="detailObj.importDate" disabled class="width220" ></el-input>
            </el-form-item>
            <el-form-item  class="form-item-block text-center" v-if="!editDisalbe">
              <el-button type="primary" @click="onSubmit()">确认</el-button>
            </el-form-item>
    </el-form>
    <hr>
    <br>
    <el-form :model="detailBObj"  v-if="detailObj.isBobj" ref="ruleForm" label-width="140px" class="demo-ruleForm" :inline="true">
        <el-form-item label="任务排程筛选人" prop="taskNo">
              <el-input v-model="detailBObj.rwPcsxWorkerName" class="width220" disabled></el-input>
        </el-form-item>
        <el-form-item label="任务排程筛选时间" prop="taskNo">
              <el-date-picker v-model="detailBObj.rwPcsxTime" type="datetime" class="width220" disabled></el-date-picker>
        </el-form-item>        
        <el-form-item label="任务排程人" prop="taskNo">
              <el-input v-model="detailBObj.rwPcWorkerName" class="width220" disabled></el-input>
        </el-form-item>
        <el-form-item label="任务排程时间" prop="taskNo">
              <el-date-picker v-model="detailBObj.rwPcTime" type="datetime" class="width220" disabled></el-date-picker>
        </el-form-item>
        <el-form-item label="任务接收操作者" prop="taskNo">
              <el-input v-model="detailBObj.rwXfWorkers" class="width220" disabled></el-input>
        </el-form-item>
        <br>
        <el-form-item label="任务下发人" prop="taskNo">
              <el-input v-model="detailBObj.rwXfCreatorName" class="width220" disabled></el-input>
        </el-form-item> 
        <el-form-item label="任务下发时间" prop="taskNo">
              <el-date-picker v-model="detailBObj.rwXfTime" type="datetime" class="width220" disabled></el-date-picker>
        </el-form-item>
        <el-form-item label="任务签收人" prop="taskNo">
              <el-input v-model="detailBObj.rwQsWorkerName"  class="width220" disabled></el-input>
        </el-form-item>
        <el-form-item label="任务签收时间" prop="taskNo">
              <el-date-picker v-model="detailBObj.rwQsTime" type="datetime" class="width220" disabled></el-date-picker>
        </el-form-item> 
        <el-form-item label="任务开工人" prop="taskNo">
              <el-input v-model="detailBObj.rwKgWorkerName"  class="width220" disabled></el-input>
        </el-form-item>
        <el-form-item label="任务开工时间" prop="taskNo">
              <el-date-picker v-model="detailBObj.rwKgTime" type="datetime" class="width220" disabled></el-date-picker>
        </el-form-item>
        <el-form-item label="任务完工人" prop="taskNo">
              <el-input v-model="detailBObj.rwWgWorkerName"  class="width220" disabled></el-input>
        </el-form-item>
        <el-form-item label="任务完工时间" prop="taskNo">
              <el-date-picker v-model="detailBObj.rwWgTime" type="datetime" class="width220" disabled></el-date-picker>
        </el-form-item>
    </el-form>
  </div>
</template>
<script>
import planApi from 'plugins/axios/planApi.js';
import purchaseApi from 'plugins/axios/purchaseApi.js';
import salesApi from 'plugins/axios/salesApi.js';
export default {
  name: 'taskDetail29',
  props:{
    detailObj:{
      type:Object
    },
    type:{
      type:String
    },
    editDisalbe:{
      type:Boolean
    },
    isChange:{
      type:Boolean
    }

  },
  data (){
    return {
      detailBObj:'',
    }
  },
  watch:{
    isChange(){
      this.selectProcessDetailGc();
    }
  },
  created(){
    this.$nextTick(()=>{
      if(this.detailObj.isBobj){
        this.selectProcessDetailGc();
      }
    })
  },
  methods:{
    selectProcessDetailGc(){
      let self = this;
      planApi.selectProcessDetailGc(self.detailObj.processDetailId).then(res=>{
          self.detailBObj = res.content;
      });
    },
    onSubmit(){
      let self = this;
     
      self.detailObj.issueDate = self.detailObj.issueDate? self.timestampToTime( self.detailObj.issueDate):null;
      self.detailObj.wbPlanFinsihDate = self.detailObj.wbPlanFinsihDate? self.timestampToTime( self.detailObj.wbPlanFinsihDate):null;
      self.detailObj.planFinsihDate =  self.detailObj.planFinsihDate?self.timestampToTime( self.detailObj.planFinsihDate):null;
      let postData=JSON.parse(JSON.stringify(self.detailObj));
      delete postData.customerName;
      planApi.insertUpdatePlanTask1(self.type,postData).then(res=>{
        self.$emit('editSuccess');
         this.$message({
          message: '修改成功',
          type: 'success'
        });
      })
    },
    querySearchAsync(queryString, callback){
      salesApi.customerInfoListByName({keyWord:queryString?queryString:''}).then(res=>{
        res.content.forEach(item=>{
          item.value = item.name;
        })
         callback(res.content);
      })
    },
    handleSelect(item){
      this.detailObj.customer = item.id;
    }
  }
}
</script>
<style lang="stylus" scoped>

</style>